package com.eos.control.action.customer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysProductBusinessService;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysColour;
import com.hf.utils.PaginationBean;

public class ColorListAction extends AbstractBaseAction {
	private static final long serialVersionUID = 4959221649386879763L;
	private String colorName;
	private String dealFlag;
	private Integer pageNum;
	private Integer numPerPage;
	private List<SysColour> colorList;
	private Integer totalCount;

	public String getColorName() {
		return colorName;
	}

	public void setColorName(String colorName) {
		this.colorName = colorName;
	}

	public String getDealFlag() {
		return dealFlag;
	}

	public void setDealFlag(String dealFlag) {
		this.dealFlag = dealFlag;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	public List<SysColour> getColorList() {
		return colorList;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute() {
		try{
			if(null == pageNum || pageNum.intValue() ==0) pageNum = 1;
			if(null == numPerPage || numPerPage.intValue() ==0) numPerPage = PAGE_SIZE;
			SysProductBusinessService spbs = new SysProductBusinessService();
			Map<String, String> map = new HashMap<String, String>();
			map.put("deal_flag", dealFlag);
			map.put("colour_name", colorName);
			map.put("page_size", numPerPage+"");
			map.put("cur_page", pageNum+"");
			map.put("table_name", "sys_colour");
			PaginationBean pageBean = spbs.getSysColorList(map);
			totalCount = null != pageBean ? pageBean.getMaxcount() : 0;
			colorList = null != pageBean ? (List<SysColour>)pageBean.getResultList() : null;
		}catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
